<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>首页</title>
<script type="text/javascript" src="${_front_js}/jquery.min.js"></script>
<link rel="shortcut icon" href="/static/favicon.ico"/>
<link rel="stylesheet" type="text/css" href="${_front_css}/base.css">
<link rel="stylesheet" type="text/css" href="${_front_css}/home.css">
<link rel="stylesheet" type="text/css" href="${_front_css}/account/change_detail.css">
<!--[if IE]>
<script src="js/themes/html5.js"></script>
<script src="js/themes/respond.js"></script>
<script src="js/themes/excanvas.js"></script>
<![endif]-->
</head>
<body>

<!-- 头部 开始 -->
<#include "../base/top.ftl" />
<!-- 头部 结束 -->
<div class="top_border"></div>
<div class="commonwidth">
	<div class="content_bg">
	<div class="topBox">
    	<div class="analyse">
    		<input type="hidden" id="changeId" value="<#if model.id?exists>${model.id}</#if>">
        	<div class="title">
            	<span class="tit fl" style="padding-left: 10px;">
	            	<#if model.title??>
	            		${model.title}
	            	</#if>
            	</span>
            </div>  
            <div style=" margin-left:20px;">  
            <ul class="analyseData">
            	<li>
                	<p class="fontShow red">
                	<#if model.percent??>
	            		${model.percent?string('0.00')}<span>%</span>
	            	</#if>
                	</p>
                    <p class="name">年化收益率</p>
                </li>
            	<li>
                	<p class="fontShow red">
                	<#if model.money??>
                		<#if (model.amount != 0 )>
                    		${model.amount?string('0.00')}<span>元</span>
                    	<#else>
                    	 	0.00<span>元</span>
                    	</#if>
                	</#if>
                	</p>
                    <p class="name">债权总额</p>
                </li>
                <li>
                	<p class="fontShow">
                		<#if model.min??>
                    		<#if (model.min != 0 )>
                        		${model.min?string('0.00')}<span>元</span>
                        	<#else>
                        	 	0.00<span>元</span>
                        	</#if>
                    	</#if>
                	</p>
                    <p class="name">竞拍底价</p>
                </li>
                <li>
                	<p class="fontShow">
                		<#if model.period??>
							<#if model.period??>
	                            ${model.period}<span>期</span>
	                        </#if>
	                    </#if>
                	</p>
                    <p class="name">转让期数</p>
                </li>
            </ul>  
            <ul class="analyseInfo">
            	<li>
            		<span>发布时间：</span>
            		<#if model.createTime??>
                        ${(model.createTime?string("yyyy-MM-dd HH:mm:ss"))!}	
                    </#if>
            	</li>
                <li id="showTime">
                	<span></span>
               	</li>
                <li>
                	<span>到期时间：</span>
                	<#if model.overdue?exists>
                        ${(model.overdue?string("yyyy-MM-dd HH:mm:ss"))!}	
                    </#if>
                </li>
                <li>
                	<span>债权转让状态：</span>
					<#if model.status??>
                        <#if model.status=="Y">
                        	已完成
                        <#elseif model.status=="T">
                        	未完成
                        <#elseif model.status=="N">
                        	已取消
                        </#if>	
                    </#if>
                </li>
            </ul>       
            </div> 
        </div>
        <#if userAccount?exists>
        		<!-- 登录之后显示-->
				<div class="right">
					<div class="div-one">
						<div class="size-16 pull-left">购买债权</div>
					</div>
					<div class="div-two color-blue">
						债权总额：
						<span>
	        				${model.amount}
	        			</span>元
					</div>
					<form id="investmentFrom" novalidate="novalidate">
						<div class="div-three">
							<div class="pull-left">
								<input type="text" id="amount" name="amount" value="${model.min}" readonly class="money-text" placeholder="请输入投资金额">
								<p class="annotate" style="color: red; line-height: 14px; height: 14px; margin: 5px 0px 0px;"></p>
							</div>
							<div class="pull-right">
								<input type="button" onclick="change()" value="立即承接" class="money-btn Bid-btn">
							</div>
						</div>
						<div class="div-four" style="border-bottom: 0px solid;margin-bottom:5px;">
							<div class="pull-right">
								
							</div>
						</div>
					</form>
					<div style="border-bottom: 1px solid #e1e1e1;"></div>
					<div class="div-five">
						<div class="pull-left">账户余额 
							<a href="javascript:void(0);" style="color: #f26633;">
								<#if userAccount.balance?exists>
				            		<#if (userAccount.balance != 0 )>
			        					￥${userAccount.balance?string('0.00')}
			        				<#else>
			        					￥0.00
			        				</#if>
			            		</#if>
		            		</a> 
		            	</div>
						<div class="pull-right">
							<a href="/account/recharge" target="_blank" style="color: #0068b7;">立即充值</a>
						</div>
					</div>
				</div>        
        <#else>
        	<!-- begin 登录之前显示-->
				<div class="right">
					<div class="div-one">
						<div class="size-16 pull-left">购买债权</div>
					</div>
					<div class="div-two color-blue">
						债权总额：
						<span>
	        				${model.amount}
	        			</span>元
					</div>
					<form id="investmentFrom" novalidate="novalidate">
						<div class="div-three">
								<input type="button" onclick="javascript:window.location.href='/login';" style="width:320px" value="立即登录" class="money-btn Bid-btn">
						</div>
						<div class="div-four" style="border-bottom: 0px solid;margin-bottom:5px;">
						<div class="pull-right">
						</div>
						</div>
					</form>
					<div style="border-bottom: 1px solid #e1e1e1;"></div>
					<div class="div-five">
						<div class="pull-left"><a href="/login" class="color-orange" style="color:#f26633;">温馨提示：</a>您还没有登录，请先登录后才能购买</div>
					</div>
				 </div>
	        <!-- end 登录之前显示-->
        </#if>
    </div>
    </div>
    <div class="investmentTab">
	        <div class="clear"></div>
	        <div class="tab_box">
			<div class="commonTable" style="margin-left: -50px">
                <p class="tit commonMarginTop" id="tab3">转让记录</p>
            	<table cellpadding="0" cellspacing="0">
                	<tbody>
                		<tr>
	                		<td>序号</td>
	                        <td>承接人</td>
	                        <td>转让金额</td>
	                        <td>转让时间</td>
                		</tr>
                	</tbody>
                	<tbody id="resultList">
                	<#if (list?? & list?size > 0)>
						<#list list as model>
							<tr>
								<td>
                                    ${model_index+1}
                                </td>
                                <td>
                                	<#if model.username?exists>
	                                    ${model.username[0..1]}*** 
                                	</#if>
                                </td>
                                <td>
                                	￥
                                	<#if model.amount?exists>
                                		<#if (model.amount != 0 )>
                                			${model.amount?string('#.00')}
	                                	<#else>
	                                	 	${model.amount?string('0.00')}
	                                	</#if>
                                	</#if>	
                                </td>
                                <td>
                                    <#if model.createTime?exists>
                            			${(model.createTime?string("yyyy-MM-dd HH:mm:ss"))!}	
                            		</#if> 
                                </td>
							</tr>
                		</#list>
                	<#else>
                		<tr>
                			<td colspan="4">暂无数据</td>
                		</tr>	
                	</#if>
                	</tbody>
                </table> 
				</div>
	        </div>    
        </div>
    </div>
</div>
<!-- 底部 开始 -->
<#include "../base/foot.ftl" />
<!-- 底部 结束 -->

<script type="text/javascript" src="${_front_js}/layer/layer.js" ></script>
<script type="text/javascript" src="${_front_js}/layer/extend/layer.ext.js" ></script>

<script type="text/javascript">
	
	function change(){
    	var changeId = $("#changeId").val();
    	var amount = $("#amount").val();

		$.ajax({
			type: "POST",
            url: '/user/change/save',
            data:{changeId:changeId,dealPwd:dealPwd},
            async: false,
            success: function(result) {
            	if(result.code == -1){
            		window.location.href="/loan/borrow/change?changeId="+changeId;
            		return false;
            		layer.alert("购买成功!", function(index){
					    layer.close(index);
					    window.location.reload();
					});  
            	}else{
            		layer.alert(result.msg, function(index){
					    layer.close(index);
	            		if(result.code == 6){
	            			localStorage.setItem("backURL",window.location.href);
	            			window.location.href="/user/account/setSafePayPWD";
	            		}					    
					});  
            	}
            }
	    })	
	}
	
	$("#changeLogin").click(function(){
    	localStorage.setItem("loginurl",window.location.href);
    	window.location.href = "/login";
	});
</script>
</body>
</html>
